﻿using System.Windows.Controls;

namespace CommonUtils
{
    public static class CheckBoxUtil
    {
        public static void Save(this CheckBox checkBox)
        => CacheUtil.SaveWithFile(checkBox.Name, checkBox.IsChecked.Value);

        public static void SaveOnChange(this CheckBox checkBox)
        => checkBox.Click += delegate { checkBox.Save(); };

        public static void Load(this CheckBox checkBox)
        => checkBox.IsChecked = CacheUtil.GetFromFile<bool>(checkBox.Name);
    }
}
